package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.LoanOffset;
import com.ruoyi.bizsys.service.ILoanOffsetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 借据冲账管理Controller
 *
 * @author african-loan
 * @date 2021-12-30
 */
@RestController
@RequestMapping("/business/LoanOffset")
public class LoanOffsetController extends BaseController {
    @Autowired
    private ILoanOffsetService loanOffsetService;

/**
 * 查询借据冲账管理列表
 */
@PreAuthorize("@ss.hasPermi('business:LoanOffset:list')")
@GetMapping("/list")
        public TableDataInfo list(LoanOffset loanOffset) {
        startPage();
        List<LoanOffset> list = loanOffsetService.getList(loanOffset);
        return getDataTable(list);
    }
    
    /**
     * 导出借据冲账管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:LoanOffset:export')")
    @Log(title = "借据冲账管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LoanOffset loanOffset) {
        List<LoanOffset> list = loanOffsetService.getList(loanOffset);
        ExcelUtil<LoanOffset> util = new ExcelUtil<LoanOffset>(LoanOffset.class);
        return util.exportExcel(list, "LoanOffset");
    }

    /**
     * 获取借据冲账管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:LoanOffset:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(loanOffsetService.selectLoanOffsetById(id));
    }

    /**
     * 新增借据冲账管理
     */
    @PreAuthorize("@ss.hasPermi('business:LoanOffset:add')")
    @Log(title = "借据冲账管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LoanOffset loanOffset) {
        return toAjax(loanOffsetService.insertLoanOffset(loanOffset));
    }

    /**
     * 修改借据冲账管理
     */
    @PreAuthorize("@ss.hasPermi('business:LoanOffset:edit')")
    @Log(title = "借据冲账管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LoanOffset loanOffset) {
        return toAjax(loanOffsetService.updateLoanOffset(loanOffset));
    }

    /**
     * 删除借据冲账管理
     */
    @PreAuthorize("@ss.hasPermi('business:LoanOffset:remove')")
    @Log(title = "借据冲账管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(loanOffsetService.deleteLoanOffsetByIds(ids));
    }
}
